﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TextureCreatDemo : MonoBehaviour
{
    void Start()
    {
        //Texture2D texture = new Texture2D(128, 128);
        //GetComponent<Renderer>().material.mainTexture = texture;

        //for (int y = 0; y < texture.height; y++)
        //{
        //    for (int x = 0; x < texture.width; x++)
        //    {
        //        Color color = ((x & y) != 0 ? Color.white : Color.gray);
        //        texture.SetPixel(x, y, color);
        //    }
        //}
        //texture.Apply();
        Texture2D texture = new Texture2D(2, 2);
        Color color = new Color(0, 1, 1, 0);
      
        // texture.SetPixel(0, 0, Color.red);
        //texture.SetPixel(0, 1, Color.green);
        //texture.SetPixel(1, 1, Color.blue);
        //texture.SetPixel(1, 0, Color.yellow);
        for (int y = 0; y < texture.height; y++)
        {
            for (int x = 0; x < texture.width; x++)
            {
                //Color color = ((x & y) != 0 ? Color.white : Color.gray);
                texture.SetPixel(x, y, color);
            }
        }
        texture.SetPixel(0, 0, Color.red);
        texture.Apply();
        GetComponent<Renderer>().material.mainTexture = texture;
    }


}
